package tyk.preparedstatement;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/***
 *@title sub
 *@description <TODO description class purpose>
 *@author Tang'ya'kang
 *@VERSION 1.0.0
 *@CREATE 2023/5/4 21:11
 **/
public class sub {
    private static Connection connection;

    public sub(Connection connection) {
        this.connection = connection;
    }

    public static void subs(String account, int money) throws SQLException {
        String sql="update t_bank set money = money - ? where account = ?;";
        PreparedStatement preparedStatement=connection.prepareStatement(sql);
        preparedStatement.setObject(1,money);
        preparedStatement.setObject(2,account);
        int rows=preparedStatement.executeUpdate();
        preparedStatement.close();
    }
}
